package com.dmx.cep.dao.impl;

import java.util.Collection;
import java.util.List;

import com.dmx.cep.dao.ConfAttributeSelectionDao;
import com.dmx.cep.entity.ConfAttributeSelection;
import com.dmx.fw.dao.hibernateimpl.BaseDaoImpl;

public class ConfAttributeSelectionDaoImpl extends BaseDaoImpl implements ConfAttributeSelectionDao {

    public void batchDeleteConfAttributeSelectionByIds(Integer[] ids){
    	if(ids==null){
    		throw new IllegalArgumentException("arg ids couldn't be null for ConfAttributeSelectionDaoImpl.batchDeleteConfAttributeSelectionByIds");
    	}
        if (ids != null) {
            for(Integer id:ids){
               deleteConfAttributeSelectionById(id);
            }
        }
    }

    public void deleteConfAttributeSelectionById(Integer id){
    	ConfAttributeSelection ConfAttributeSelection =findConfAttributeSelectionById(id);
    	if(ConfAttributeSelection!=null)
    		super.getHibernateTemplate().delete(ConfAttributeSelection);
    }

    public void saveOrUpdateConfAttributeSelection(ConfAttributeSelection confAttributeSelection){
        super.getHibernateTemplate().saveOrUpdate(confAttributeSelection);
    }

    @SuppressWarnings("unchecked")
	public ConfAttributeSelection findConfAttributeSelectionById(Integer id){
    	if(id==null){
    		throw new IllegalArgumentException("arg id couldn't be null for ConfAttributeSelectionDaoImpl.deleteConfAttributeSelectionById");
    	}
        String hql = "from ConfAttributeSelection where id =?";
        List<ConfAttributeSelection> ConfAttributeSelections = this.getHibernateTemplate().find(hql,id);
        if(!ConfAttributeSelections.isEmpty())
          return ConfAttributeSelections.get(0);
        return null;
    }

	@SuppressWarnings("unchecked")
	@Override
	public ConfAttributeSelection findConfAttributeSelectionByName(String confName) {
		// TODO Auto-generated method stub
    	if(confName==null){
    		throw new IllegalArgumentException("arg confName couldn't be null for ConfAttributeSelectionDaoImpl.findConfAttributeSelectionByName");
    	}
        String hql = "from ConfAttributeSelection where confName =?";
        List<ConfAttributeSelection> ConfAttributeSelections = this.getHibernateTemplate().find(hql,confName);
        if(!ConfAttributeSelections.isEmpty())
          return ConfAttributeSelections.get(0);
        return null;
	}

	@Override
	public void saveAllConfAttributeSelections(Collection<ConfAttributeSelection> confAttributeSelections) {
		// TODO Auto-generated method stub
		
		super.getHibernateTemplate().saveOrUpdateAll(confAttributeSelections);
		
	}



	
	
}
